<?php session_start(); ?>
<?php
 if(!$_SESSION['uname']){
  echo "你没有权限访问此页面!";
  return false;
}
?>
<?php include("../inc/db_config.inc"); ?>
<?php

if(isset($_REQUEST['url'])&&$_REQUEST['url']!=""){
    $link_url=$_REQUEST['url'];
}else{
    echo "链接地址不能为空<a href='javascript:history.back()'>返回</a>";
    return false;
}
if(isset($_REQUEST['title'])&&$_REQUEST['title']!=""){
    $link_title=$_REQUEST['title'];
}else{
    echo "网站标题不能为空<a href='javascript:history.back()'>返回</a>";
    return false;
}
if(isset($_REQUEST['desc'])&&$_REQUEST['desc']!=""){
    $link_desc=$_REQUEST['desc'];
}

date_default_timezone_set("Asia/Shanghai"); //北京时间
$link_created=date("Y-m-d H:i:s");
//echo "insert into link (url,name,desc,created) values('$link_url','$link_title','$link_desc','$link_created')";
$result_post=mysql_query("insert into link (url,name,description,created) values('$link_url','$link_title','$link_desc','$link_created')");
if(mysql_affected_rows()>0){
    echo "添加成功!页面会在1秒钟后自动返回.<script type='text/javascript'>setTimeout(function(){history.back()},1000)</script>";
}else{
    echo "添加失败!<a href='javascript:history.back()'>返回</a>";
}
 ?>